package com.nan.translation.service;


import com.nan.translation.model.User;
import com.nan.translation.respository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {
    private final UserRepository userRepository;

    @Autowired
    public UserService(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Transactional(isolation = Isolation.SERIALIZABLE)
    public User findUserByName(String name){
        return userRepository.findUserByName(name);
    }

    @Transactional(isolation = Isolation.SERIALIZABLE)
    public User addUser(User user){
        return userRepository.save(user);
    }
}
